package com.td.module.system.dal.mysql.growth;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.system.controller.admin.growth.vo.list.GrowthModuleListExportReqVO;
import com.td.module.system.controller.admin.growth.vo.list.GrowthModuleListPageReqVO;
import com.td.module.system.dal.dataobject.growth.GrowthModuleListDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 生长模型列 Mapper
 *
 * @author wangxx
 */
@Mapper
public interface GrowthModuleListMapper extends BaseMapperX<GrowthModuleListDO> {

    default PageResult<GrowthModuleListDO> selectPage(GrowthModuleListPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GrowthModuleListDO>()
                .likeIfPresent(GrowthModuleListDO::getLabel, reqVO.getLabel())
                .eqIfPresent(GrowthModuleListDO::getPlantingStandardType, reqVO.getPlantingStandardType())
                .eqIfPresent(GrowthModuleListDO::getPlantingEnvironmentType, reqVO.getPlantingEnvironmentType())
                .eqIfPresent(GrowthModuleListDO::getStatus, reqVO.getStatus())
                .eqIfPresent(GrowthModuleListDO::getGrowthType, reqVO.getGrowthType())
                .betweenIfPresent(GrowthModuleListDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GrowthModuleListDO::getId));
    }

    default List<GrowthModuleListDO> selectList(GrowthModuleListExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GrowthModuleListDO>()
                .likeIfPresent(GrowthModuleListDO::getLabel, reqVO.getLabel())
                .eqIfPresent(GrowthModuleListDO::getPlantingStandardType, reqVO.getPlantingStandardType())
                .eqIfPresent(GrowthModuleListDO::getPlantingEnvironmentType, reqVO.getPlantingEnvironmentType())
                .eqIfPresent(GrowthModuleListDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(GrowthModuleListDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GrowthModuleListDO::getId));
    }

}
